In [1]:
%pylab inline
In [2]:
import pandas as pd
In [3]:
#mypath = '/fs3/group/jonasgrp/MachineLearning/Cell_types.xlsx'
mypath = './Cell_types.xlsx'
df = pd.read_excel(io=mypath, sheetname='PFC', skiprows=1)
In [4]:
df.head()
Out[4]:
In [28]:
df.columns
Out[28]:
In [43]:
df['CellID']
Out[43]:
In [44]:
for key in df.columns:
if df[key].dtype != object:
print"%-10s = %2.4f + %2.4f" %(key ,df[key].mean(), df[key].std())
In [51]:
means = df[ df.columns ].mean()
means
Out[51]:
In [54]:
df_means = pd.DataFrame(means).T
df_means.head()
Out[54]:
In [55]:
df.InputR
Out[55]:
In [56]:
df['Vrest'].mean()
Out[56]:
In [57]:
df['Vrest'].unique() # get NumPy array
Out[57]:
In [58]:
df['Sag'].plot(marker='o', color='red'); # plots
In [59]:
plt.scatter(df['InputR'], df['rheobase'], color='black')
plt.xlabel('Input Resistance (M$\Omega$)'), plt.ylabel('Rheobase (pA)')
plt.xlim(0,400), plt.ylim(0,400);
Let's evaluate how much the membrane potential depends on Input resistance and membrane time constant and the sag ratio. We will create the following multivariate function:
$f(k;x) = k_0 + k_1x_1 + k_2x_2 + k_3x_3$
where $k$ is a vector or parameters (contants) and $x$ is a vector of independent variables (i.e $x_1$ is the input resistance $x_2$ is membrane time constant and $x_3$ the sag ratio)
In [60]:
x = df[['InputR', 'Sag','Tau_mb']]
y = df[['Vrest']]
In [61]:
# import standard regression models (sm)
import statsmodels.api as sm
In [62]:
K = sm.add_constant(x) # k0, k1, k2 and k3...
In [63]:
# get estimation
est = sm.OLS(y, K).fit() # ordinary least square regression
In [64]:
est.summary() # need more data for kurtosis :)
Out[64]:
r_squared is not very large... but coef gives us the values of $k_0$, $k_1$, $k_2$, and $k_3$ to plug into the equation. Based on the standard error InputResistance and mbTau are more important than SagRatio to determine the resting membrane potential.
In [ ]: